//
//  LWSettingViewController.m
//  1.28  weibo
//
//  Created by mac on 15/3/1.
//  Copyright (c) 2015年 mac. All rights reserved.
//

#import "LWSettingViewController.h"
#import "LWProDuctItme.h"
#import "LWProductGroup.h"
#import "LWProductCell.h"
#import "LWProductArrowItme.h"
#import "LWproductLableItme.h"
#import "LWproductItmeSwitchItme.h"
#import "UIImageView+WebCache.h"
#import "CZTestController.h"

@interface LWSettingViewController ()

@end

@implementation LWSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupGroups];
}

- (void)setupGroups
{
    /** 0组 */
    [self setupGroup0];
    
    /** 1组 */
    [self setupGroup1];
    
    /** 2组 */
    [self setupGroup2];
    
    /** 3组 */
    [self setupGroup3];
    
    /** 4组 */
    [self setupGroup4];
}
- (void)setupGroup0
{
    LWproductLableItme *readMode = [LWproductLableItme initWithTitile:@"阅读模式"];
    readMode.text = @"有图模式";
    
    LWproductLableItme *font = [LWproductLableItme initWithTitile:@"字号大小"];
    font.text = @"大";
    
    LWproductItmeSwitchItme *showMark = [LWproductItmeSwitchItme initWithTitile:@"显示备注"];
    
    LWProductGroup *group = [[LWProductGroup alloc] init];
    group.itmes = @[readMode, font, showMark];
    
    [self.datas addObject:group];
}


- (void)setupGroup1
{
    LWProductArrowItme *picture = [LWProductArrowItme initWithTitile:@"图片质量设置"];
    picture.destVCName = @"LWPictureQualityViewController";
    
    LWProductGroup *group = [[LWProductGroup alloc] init];
    group.itmes = @[picture];
    
    [self.datas addObject:group];
}

- (void)setupGroup2
{
    LWproductItmeSwitchItme *voice = [LWproductItmeSwitchItme initWithTitile:@"声音"];
    
    LWProductGroup *group = [[LWProductGroup alloc] init];
    group.itmes = @[voice];
    
    [self.datas addObject:group];
}

- (void)setupGroup3
{
    LWproductLableItme *language = [LWproductLableItme initWithTitile:@"多语言环境"];
    language.text = @"跟随系统";
    
    LWProductGroup *group = [[LWProductGroup alloc] init];
    group.itmes = @[language];
    
    [self.datas addObject:group];
}

- (void)setupGroup4
{
    LWProductArrowItme *clearCache = [LWProductArrowItme initWithTitile:@"清除图片缓存"];
    NSUInteger size = [[SDWebImageManager sharedManager].imageCache getSize];
    double kbSize = size / 1000.0;
    clearCache.subTitle = [NSString stringWithFormat:@"%.1fKB",kbSize];
    if (kbSize > 1000) {
        clearCache.subTitle = [NSString stringWithFormat:@"%.1fM",kbSize / 1000.0];
    }
    
    __weak typeof(clearCache) weakClearCache = clearCache;
    __weak typeof(self) weakSelf = self;
    clearCache.option = ^{
    
        [[SDWebImageManager sharedManager].imageCache cleanDisk];
        weakClearCache.subTitle = nil;
        [weakSelf.tableView reloadData];
    };
    
    
    LWProductArrowItme *clearHistory = [LWProductArrowItme initWithTitile:@"清空搜索历史"];
    LWProductGroup *group = [[LWProductGroup alloc] init];
    group.itmes = @[clearCache, clearHistory];
    
    [self.datas addObject:group];
}
@end
